package love.yuanmengrobot.attendancesystem.servlet;
/*
 *   @Studio:CHJY · 源梦科技
 *   @Author:CHJY创幻
 *   @Ide:IntelliJ IDEA
 *   @Creation time:2021/6/22 20:25
 */

import com.google.gson.Gson;
import love.yuanmengrobot.attendancesystem.dao.AttendanceDao;
import love.yuanmengrobot.attendancesystem.dao.ClazzDao;
import love.yuanmengrobot.attendancesystem.entity.AttendanceDate;

import java.io.IOException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;

public class AttendanceDateServlet extends javax.servlet.http.HttpServlet {
    protected void doPost(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {


    }

    protected void doGet(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws javax.servlet.ServletException, IOException {


        request.setCharacterEncoding("utf-8");
        response.setContentType("text/html;charset=utf-8");

        String clazzid = request.getParameter("clazzid");

        PrintWriter pw = null;

        pw = response.getWriter();

        AttendanceDao attendanceDao = new AttendanceDao();


        ArrayList<AttendanceDate> list = null;

        list = attendanceDao.queryById(clazzid);
        if (list != null) {
            Gson gson = new Gson();
            pw.print(gson.toJson(list));
        }
        pw.flush();
        pw.close();
//        int su = 0;
//
//            if (su == 1) {
//                pw.print("{\"meg\":\"创建成功\"}");
//            } else {
//                pw.print("{\"meg\":\"创建失败\"}");
//            }


    }


}
